/**
 * 公用js
 */

/*弹出层*/
function parse_result(result) {
    if (result.status === 0) {
        layer.msg(result.msg, {icon: 6, time: 3000, shade: [0.3, '#000', true]});
        return true;
    } else {
        layer.msg(result.msg, {icon: 5, time: 3000, shade: [0.3, '#000', true]});
        return false;
    }
}

/*
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
function layer_show(title, url, w, h) {
    var width = document.documentElement.clientWidth;
    var height = document.documentElement.clientHeight;
    if (!title) title = false;
    if (!url) url = "404.html";
    if (!w) w = '90%';
    else if (width > 0 && w.indexOf("px") > 0 && width < parseInt(w.replace("px", ""))) w = width + 'px';
    if (!h) h = '90%';
    else if (height > 0 && h.indexOf("px") > 0 && height < parseInt(h.replace("px", ""))) h = height + 'px';
    var index = layer.open({
        type: 2,
        area: [w, h],
        fix: true, //不固定
        maxmin: false,
        shade: 0.4,
        title: title,
        content: url
    });
    return index;
}

//页面层-自定义
function layer_no_title(url, w, h) {
    var index = layer.open({
        type: 2,
        area: [w, h],
        title: false,
        scrollbar: false,
        resize: false,
        closeBtn: 0,
        content: url,
        success: function () {
            $("body").css("overflow", "hidden");
        },
        end: function () {
            $("body").css("overflow", "auto");
        }
    });
    return index;
}

/*关闭弹出框口*/
function layer_close() {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}